package com.example.common.view;

import android.content.Context;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.common.R;

/**
 * @author skygge
 * @date 2020/7/20.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：
 */
public class CustomEmptyView extends LinearLayout {

    private ImageView mEmptyAdd;
    private onClickCallBack mCallBack;

    public void setCallBack(onClickCallBack mCallBack) {
        this.mCallBack = mCallBack;
    }

    public CustomEmptyView(Context context) {
        super(context);
        initView(context);
    }

    public CustomEmptyView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public CustomEmptyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context){
        //绑定布局
        LayoutInflater.from(context).inflate(R.layout.layout_device_empty, this);
        //找到控件
        mEmptyAdd = findViewById(R.id.device_empty_add);
        mEmptyAdd.setOnClickListener(v -> {
            if (mCallBack!=null){
                mCallBack.onClick();
            }
        });
    }

    public interface onClickCallBack{
        void onClick();
    }
}
